package base;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

@Slf4j
public class JobDemo {

    private static final int CORE_POOL_SIZE = Runtime.getRuntime().availableProcessors();
    private static final ScheduledExecutorService exec = new ScheduledThreadPoolExecutor(CORE_POOL_SIZE * 2);

    public static void main(String[] args) {
        exec.schedule(() -> log.info("schedule"), 1, TimeUnit.SECONDS);

        exec.scheduleAtFixedRate(() -> log.info("scheduleAtFixedRate"), 2, 1, TimeUnit.SECONDS);

        exec.scheduleWithFixedDelay(() -> log.info("scheduleWithFixedDelay"), 2, 1, TimeUnit.SECONDS);
    }
}
